package com.atguigu.gmall.activity.util;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.Duration;

/**
 * Caffeine缓存对象，定义多项业务数据的缓存对象
 *
 * @author: atguigu
 * @create: 2023-08-16 09:11
 */
@Configuration
public class CacheConfig {


    /**
     * 缓存秒杀商品“状态位”对象
     * @return
     */
    @Bean
    public Cache<String, String> seckillCache() {
        return Caffeine.newBuilder()
                .maximumSize(100)
                .expireAfterWrite(Duration.ofHours(20)).build();
    }

}
